using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace Gj
{
    public class AreaMapManager : MonoBehaviour
    {
        public List<AreaMapLayer> Layers;

        private readonly bool isLoad = false;

        public IEnumerator LoadResource()
        {
            if (isLoad) yield break;
            var e = Layers.GetEnumerator();
            while (e.MoveNext())
                if (!string.IsNullOrEmpty(e.Current.Bundle))
                    yield return Resource.LoadBundle(e.Current.Bundle, e.Current.Variant, (i, b) => { },
                        e.Current.Namespace);
            e.Dispose();
        }

        public string GetAssetsPath(int layer, int index)
        {
            return Layers[layer].Indexs[index];
        }

        public int GetLayerIndex(AreaMapLayer layer)
        {
            return Layers.FindIndex(r => r == layer);
        }
    }
}